﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Collections;
using Utility.Tool;

namespace DataBase
{
    /// <summary>
    /// 数据库通用操作层接口
    /// 版本：2.0
    /// </summary>
    public interface IDbHelper
    {
        #region 返回影响行数
        object GetObjectValue(string sql);
        object GetObjectValue(string sql, Hashtable ht);
        #endregion

        #region 根据SQL执行
        int ExecuteBySql(string sql);
        int ExecuteBySql(string sql, Hashtable ht);
        int BatchExecuteBySql(string[] sql, object[] param);
        #endregion

        #region DataTable
        DataTable GetDataTable(string targetTable);
        DataTable GetDataTable(string targetTable, string orderField, string orderType);
        DataTable GetDataTableBySQL(string sql);
        DataTable GetDataTableBySQL(string sql, Hashtable ht);
        DataTable GetDataTableProc(string procName, Hashtable ht);
        DataTable GetDataTableProcReturn(string procName, Hashtable ht, ref Hashtable rs);
        #endregion

        #region 返回 IList
        IList GetDataListBySQL<T>(string sql);
        IList GetDataListBySQL<T>(string sql, Hashtable ht);
        #endregion

        #region 存储过程
        int ExecuteByProc(string procName, Hashtable ht);
        int ExecuteByProcNotTran(string procName, Hashtable ht);
        int ExecuteByProcReturnMsg(string procName, Hashtable ht, ref object rs);
        int ExecuteByProcReturn(string procName, Hashtable intputHt, ref Hashtable outputHt);
        #endregion

        #region 增、删、改、查
        bool AddOrEdit(string tableName, string pkName, string pkValue, Hashtable ht);
        int UpdateByHashtable(string tableName, string strWhere, Hashtable ht);
        Hashtable GetHashtableById(string tableName, string pkName, string pkValue);
        int IsExist(string tableName, string pkName, string pkValue);
        int InsertByHashtable(string tableName, Hashtable ht);
        int Update(string tableName, string pkName, string pkValue, Hashtable ht);
        int DeleteData(string tableName, string pkName, string pkValue);
        int BatchDelete(string tableName, string pkName, object[] pkValues);
        #endregion

        #region 数据分页
        DataTable GetPageList(string sql, Hashtable ht, string sortBy, int pageIndex, int pageSize, ref int count);
        DataTable GetPageList(string tableName, string primaryKey, string showFields, int pageIndex, int pageSize, string whereStr, string sortBy, ref int count);
        #endregion

        #region BulkCopy 批量导入数据库
        bool BulkCopyImport(DataTable dt);
        #endregion
    }
}
